package com.ziyueyuwen.xiniao.dao;

import com.ziyueyuwen.xiniao.bean.product.ZyOrderDO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

import static com.ziyueyuwen.xiniao.util.ConstUtil.*;

/**
 * @author jun 2019/2/23
 */
public interface ZyOrderMapper {

    /**
     * 创建订单
     *
     * @param zyOrderDO ZyOrderDO
     * @return Boolean
     */
    Boolean add(ZyOrderDO zyOrderDO);

    /**
     * 微信支付后回调更新
     *
     * @param zyOrderDO ZyOrderDO
     * @return Boolean
     */
    Boolean updateByWxNotify(ZyOrderDO zyOrderDO);

    /**
     * 根据outTradeNo获取订单
     *
     * @param outTradeNo String
     * @return ZyOrderDO
     */
    ZyOrderDO getByOutTradeNo(String outTradeNo);

    /**
     * 获取订单列表
     *
     * @param productName String
     * @param userAccount String
     * @param userName    String
     * @return JSONObject
     */
    List<ZyOrderDO> listOrder(@Param(KEY_PRODUCT_NAME) String productName,
                              @Param(KEY_USER_ACCOUNT) String userAccount,
                              @Param(KEY_USER_NAME) String userName);

    /**
     * 获取订单列表
     *
     * @param productName String
     * @param userAccount String
     * @param userName    String
     * @return JSONObject
     */
    List<ZyOrderDO> listSendOrder(@Param(KEY_PRODUCT_NAME) String productName,
                                  @Param(KEY_USER_ACCOUNT) String userAccount,
                                  @Param(KEY_USER_NAME) String userName);


    /**
     * 备注订单
     *
     * @param id     Integer
     * @param remark String
     * @return Boolean
     */
    Boolean remarkOrder(@Param(KEY_ID) Integer id,
                        @Param(KEY_REMARK) String remark);

    /**
     * 标记寄送书
     *
     * @param id Integer
     * @return Boolean
     */
    Boolean sendBook(Integer id);

    /**
     * 检查用户是否已经买过此商品
     *
     * @param userAccount String
     * @param classId     Integer
     * @return Boolean
     */
    Boolean checkHaveBuyProduct(@Param(KEY_USER_ACCOUNT) String userAccount,
                                @Param(KEY_CLASS_ID) Integer classId);
}
